package com.topc.problem.model.enums;

import cn.hutool.core.util.ObjectUtil;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum LanguageTypeEnum {

    C(1,"c"),

    CPLUSPLUS(2,"cpp"),

    JAVA(3,"java"),

    GOLANG(4,"go"),

    PYTHON(5,"python");

    LanguageTypeEnum(Integer text, String value) {
        this.text = text;
        this.value = value;
    }

    private final Integer text;

    private final String value;



    public static List<String> getValues() {
        return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
    }

    public static LanguageTypeEnum getEnumByValue(String value) {
        if (ObjectUtil.isEmpty(value)) {
            return null;
        }
        for (LanguageTypeEnum anEnum : LanguageTypeEnum.values()) {
            if (anEnum.value.equals(value)) {
                return anEnum;
            }
        }
        return null;
    }

    public static LanguageTypeEnum getEnumByText(Integer text) {
        if (ObjectUtil.isEmpty(text)) {
            return null;
        }
        for (LanguageTypeEnum anEnum : LanguageTypeEnum.values()) {
            if (anEnum.text.equals(text)) {
                return anEnum;
            }
        }
        return null;
    }

    public String getValue() {
        return value;
    }

    public Integer getText() {
        return text;
    }


}
